package com.ruoyi.st.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.st.domain.StTicketDate;
import com.ruoyi.st.service.IStTicketDateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 票面日期Controller
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/st/ticketDate")
public class StTicketDateController extends BaseController
{
    @Autowired
    private IStTicketDateService stTicketDateService;

    /**
     * 查询票面日期列表
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:list')")
    @GetMapping("/list")
    public TableDataInfo list(StTicketDate stTicketDate)
    {
        startPage();
        List<StTicketDate> list = stTicketDateService.selectStTicketDateList(stTicketDate);
        return getDataTable(list);
    }

    /**
     * 导出票面日期列表
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:export')")
    @Log(title = "票面日期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StTicketDate stTicketDate)
    {
        List<StTicketDate> list = stTicketDateService.selectStTicketDateList(stTicketDate);
        ExcelUtil<StTicketDate> util = new ExcelUtil<StTicketDate>(StTicketDate.class);
        util.exportExcel(response, list, "票面日期数据");
    }

    /**
     * 获取票面日期详细信息
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stTicketDateService.selectStTicketDateById(id));
    }

    /**
     * 新增票面日期
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:add')")
    @Log(title = "票面日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StTicketDate stTicketDate)
    {
        return toAjax(stTicketDateService.insertStTicketDate(stTicketDate));
    }

    /**
     * 修改票面日期
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:edit')")
    @Log(title = "票面日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StTicketDate stTicketDate)
    {
        return toAjax(stTicketDateService.updateStTicketDate(stTicketDate));
    }

    /**
     * 删除票面日期
     */
    @PreAuthorize("@ss.hasPermi('st:ticketDate:remove')")
    @Log(title = "票面日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stTicketDateService.deleteStTicketDateByIds(ids));
    }
}
